package tudolist.bean;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import org.jgenesis.bean.BasicBean;


@Entity
@Table(name="users")
@SequenceGenerator(name="SEQUENCE", sequenceName="users_id_seq")
@NamedQueries({
	@NamedQuery(name="authenticate", query="from User u where u.name = :name and u.password = :password")
})
public class User extends BasicBean {

	private static final long serialVersionUID = -1556991960180293599L;

	
	private String name;

	@Column(name="admin")
	private boolean administrator;
	
	@Column(name="passwd")
	private String password;
	
	@OneToMany
	@JoinColumn(name="owner_id")
	private List<TaskList> taskLists;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public List<TaskList> getTaskLists() {
		return taskLists;
	}

	public void setTaskLists(List<TaskList> taskLists) {
		this.taskLists = taskLists;
	}

	public boolean isAdministrator() {
		return administrator;
	}

	public void setAdministrator(boolean admin) {
		this.administrator = admin;
	}
}